<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
  
      <el-table v-loading="loading" :data="aiRequestRecordsList">
        <el-table-column label="日期" align="center" prop="dateTime" />
        <el-table-column label="销售发送量" align="center" prop="chatNum" />
        <el-table-column label="客户点击量" align="center" prop="clickNum" />
        <el-table-column label="注册人数" align="center" prop="registerNum" />
        <el-table-column label="AI体验率" align="center" prop="aiUsageRate" >
            <template #default="scope">
                {{ scope.row.aiUsageRate }}%
            </template>
        </el-table-column>
        <el-table-column label="点击门店量" align="center" prop="clickShopNum" />
      </el-table>
  
      <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
</template>

<script setup name="AiUsage">
import {getAiUsageDataListApi} from "@/api/system/aiRequestRecords";

const { proxy } = getCurrentInstance();
const aiRequestRecordsList = ref([]);
const loading = ref(true);
const total = ref(0);
const data = reactive({
queryParams: {
    pageNum: 1,
    pageSize: 10,
},
});

const { queryParams } = toRefs(data);

function getList() {
    loading.value = true;
    getAiUsageDataListApi(queryParams.value).then(response => {
        aiRequestRecordsList.value = response.rows;
        total.value = response.total;
        loading.value = false;
    });
}


function handleQuery() {
    queryParams.value.pageNum = 1;
    getList();
}

/** 重置按钮操作 */
function resetQuery() {
    proxy.resetForm("queryRef");
    handleQuery();
}
getList();

</script>
<style lang="scss" scoped>

</style>
